<?php

namespace App\Jobs\Message;

use App\Services\SmsService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class SendSms implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected string $phone;

    protected string $type;

    protected int $memberId;

    protected array $data;

    public function __construct(string $phone, string $type, int $memberId, array $data = [])
    {
        $this->phone = $phone;
        $this->type = $type;
        $this->memberId = $memberId;
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        SmsService::instance()->sendTemplate($this->phone, $this->type, $this->memberId, $this->data);
    }
}
